<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User_model extends CI_Model
{
	
	public function __construct()
	{
		parent::__construct();

	} 	
		
	public function create_user_type($insert)
	{
		$this->db->insert('user_type',$insert);
	}
	
	/**
	* 
	* department functions
	* 
*/
	
	public function create_department($insert)
	{
		$this->db->insert('department',$insert);
	}
	
	public function get_department_by_id($id){
	return $this->db->get_where('department',array('id'=>$id))->row_array();
	}
	
	public function delete_department($id){
		$this->db->delete('department',array('id'=>$id));	
	}	
	public function update_department($id,$update){
		$this->db->update('department',$update,$id);
	}
	
	//ends here 
	
	
	public function get_employees(){
		//$this->db->get_where('users_groups');
		$this->db->select('users.*');
		$this->db->from('users_groups');
		$this->db->join('users','users_groups.user_id = users.id');
		$this->db->where('users_groups.group_id !=',1);
		$this->db->where('users_groups.group_id !=',7);
		//$this->db->get();
		//return $this->db->last_query();
		return $this->db->get()->result();
	}
	public function get_founders(){
		//$this->db->get_where('users_groups');
		$this->db->select('users.*');
		$this->db->from('users_groups');
		$this->db->join('users','users_groups.user_id = users.id');
		$this->db->where('users_groups.group_id =',1);		
		return $this->db->get()->result();
	}
	
	public function get_clients(){
		$this->db->select('users.*');
		$this->db->from('users_groups');
		$this->db->join('users','users_groups.user_id = users.id');
		$this->db->where('users_groups.group_id =',7);		
		return $this->db->get()->result();
	}
	
	
	
}
